package com.aaa.ssm.controller;

import com.aaa.ssm.entity.Department;
import com.aaa.ssm.entity.Disease;
import com.aaa.ssm.service.impl.DiseaseServiceImpl;
import com.aaa.ssm.util.Page;
import com.aaa.ssm.util.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("disease")
public class DiseaseController extends BaseController{
    @Resource
    private DiseaseServiceImpl diseaseService;
    @PostMapping("queryByPage")
    //@ResponseBody
    public Result queryByPage(@RequestBody Page<Disease> page){
        return success(diseaseService.queryByPage(page));
    }

    @PostMapping("queryByParam")
    //@ResponseBody
    public Result queryByParam(@RequestBody Page<Disease> page) {
      /*  List<Disease> diseaseList = diseaseService.queryByParam(disease);*/
        return success(diseaseService.queryByParam(page));
    }
    @GetMapping("queryById")
    //@ResponseBody
    public Result queryById(Integer diseaseId){
        return success(diseaseService.queryById(diseaseId));
    }
    @PutMapping ("add")
    //@ResponseBody
    public Result add(@RequestBody Disease disease){
        return success(diseaseService.add(disease));
    }

    @PutMapping("update")
    //@ResponseBody
    public Result update(@RequestBody Disease disease){
        return success(diseaseService.update(disease));
    }

    @DeleteMapping("deleteById")
    //@ResponseBody
    public Result deleteById(Integer diseaseId){
        return success(diseaseService.deleteById(diseaseId));
    }

    @GetMapping("queryDisease")
    public Result queryDisease(Integer departmentId){
        return success(diseaseService.queryDisease(departmentId));
    }


    // 获取所有科室信息的接口
    @GetMapping("departments")
    public List<Department> getAllDepartments() {
        return diseaseService.getAllDepartments();
    }

}
